import React from 'react'
import { Space, Table, Tag,Button, Switch } from 'antd';
import useBtn from '../../hooks/useBtn';
function Index() {
  let view =useBtn('view')
  let add =useBtn('add')
  let del =useBtn('del')
  let edit =useBtn('edit')
  const columns = [
    {
    title: 'ID',
    dataIndex: 'key',
    key: 'key',
    render: (text) => <a>{text}</a>,
  },
  {
    title: '公司名称',
    dataIndex: 'name',
    key: 'name',
    render: (text) => <a>{text}</a>,
  },
  {
    title: '年龄',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: '手机号',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    render:(text)=>{
       return <div>
          <Switch defaultValue={text}></Switch>
       </div>
    }
  },
 
  {
    title: '操作',
    key: 'action',
    render: (_, record) => (
      <Space size="middle">
        <a>
          {
            view && <Button>查看</Button>
          }
        </a>
        <a> {
            add && <Button>新增</Button>
          }</a>
        <a> {
            del && <Button>删除</Button>
          }</a>
        <a> {
            edit && <Button>编辑</Button>
          }</a>
      </Space>
    ),
  },
];
const data = [
  {
    key: '1',
    name: '上海有限公司',
    age: 32,
    address: '123456789001',
    status:1
  },
  {
    key: '2',
  name: '上海有限公司',
    age: 42,
    address: '123456789001',
    status:0
  },
  {
    key: '3',
    name: '上海有限公司',
    age: 32,
    address: '123456789001',
  
    status:1
  },
  {
    key: '1',
   name: '上海有限公司',
    age: 32,
   address: '123456789001',
    
    status:0
  },
  {
    key: '2',
    name: '上海有限公司',
    age: 42,
   address: '123456789001',
    
    status:1
  },
  {
    key: '3',
   name: '上海有限公司',
    age: 32,
    address: '123456789001',
   
    status:0
  },
  {
    key: '1',
   name: '上海有限公司',
    age: 32,
    address: '123456789001',
    
    status:1
  },
  {
    key: '2',
   name: '上海有限公司',
    age: 42,
   address: '123456789001',
    
    status:0
  },
  {
    key: '3',
    name: '上海有限公司',
    age: 32,
     address: '123456789001',
   
    status:1
  },
];
  return (
    <div>
   <Table columns={columns} dataSource={data} />;
    </div>
  )
}

export default Index
